#define RECORD_LEN 344
-static FILE *fin;
+static gbfile *fin;
static
arglist_t axim_gpb_args[] = {
static void
axim_gpb_rd_init(const char *fname)
{
- fin = xfopen(fname, "rb", MYNAME);
+ fin = gbfopen(fname, "rb", MYNAME);
}
static void
axim_gpb_rd_deinit(void)
{
- fclose(fin);
+ gbfclose(fin);
}
static void
char buff[RECORD_LEN];
route_head *track = NULL;
size_t bytes;
- long filesize, left;
- fseek(fin, 0, SEEK_END);
- filesize = ftell(fin);
-
- left = filesize - ((filesize / RECORD_LEN) * RECORD_LEN);
- is_fatal((left != 0), MYNAME ": Invalid or unsupported file (filesize).");
-
- fseek(fin, 0, SEEK_SET); /* seek file to start */
-
- while ((bytes = fread(buff, 1, RECORD_LEN, fin)))
+ while ((bytes = gbfread(buff, 1, RECORD_LEN, fin)))
{
+ is_fatal((bytes != RECORD_LEN), MYNAME ": Invalid or unsupported file (filesize).");
if (track == NULL)
{
track = route_head_alloc();
static waypoint *wpt_tmp;
-static FILE *ofd;
+static gbfile *ofd;
static
arglist_t geo_args[] = {
static void
geo_wr_init(const char *fname)
{
- ofd = xfopen(fname, "w", MYNAME);
+ ofd = gbfopen(fname, "w", MYNAME);
}
static void
geo_wr_deinit(void)
{
- fclose(ofd);
+ gbfclose(ofd);
}
static void
{
char *tmp;
- fprintf(ofd, "<waypoint>\n");
- fprintf(ofd, "<name id=\"%s\">", waypointp->shortname);
- fprintf(ofd, "<![CDATA[%s]]>", waypointp->description);
- fprintf(ofd, "</name>\n");
+ gbfprintf(ofd, "<waypoint>\n");
+ gbfprintf(ofd, "<name id=\"%s\">", waypointp->shortname);
+ gbfprintf(ofd, "<![CDATA[%s]]>", waypointp->description);
+ gbfprintf(ofd, "</name>\n");
- fprintf(ofd, "<coord lat=\"%lf\" lon=\"%lf\"/>",
+ gbfprintf(ofd, "<coord lat=\"%lf\" lon=\"%lf\"/>",
waypointp->latitude,
waypointp->longitude);
- fprintf(ofd, "\n");
+ gbfprintf(ofd, "\n");
if (waypointp->icon_descr) {
- fprintf(ofd, "<type>%s</type>\n", deficon ? deficon : waypointp->icon_descr);
+ gbfprintf(ofd, "<type>%s</type>\n", deficon ? deficon : waypointp->icon_descr);
}
if (waypointp->url) {
tmp = xml_entitize(waypointp->url);
- fprintf(ofd, "<link text =\"Cache Details\">%s</link>\n",
+ gbfprintf(ofd, "<link text =\"Cache Details\">%s</link>\n",
tmp);
xfree(tmp);
}
- fprintf(ofd, "</waypoint>\n");
+ gbfprintf(ofd, "</waypoint>\n");
}
static void
geo_write(void)
{
- fprintf(ofd, "<?xml version=\"1.0\"?><loc version=\"1.0\" src=\"EasyGPS\">\n");
+ gbfprintf(ofd, "<?xml version=\"1.0\"?><loc version=\"1.0\" src=\"EasyGPS\">\n");
waypt_disp_all(geo_waypt_pr);
- fprintf(ofd, "</loc>\n");
+ gbfprintf(ofd, "</loc>\n");
}
ff_vecs_t geo_vecs = {
#include "holux.h"
-static FILE *file_in;
+static gbfile *file_in;
static unsigned char *HxWFile;
static short_handle mkshort_handle;
static char fOutname[256];
static void rd_init(const char *fname)
{
- file_in = xfopen(fname, "rb", MYNAME);
+ file_in = gbfopen_le(fname, "rb", MYNAME);
}
static void rd_deinit(void)
{
- fclose(file_in);
+ gbfclose(file_in);
}
HxWpt = xcalloc(GM100_WPO_FILE_SIZE, 1);
/* read the wpo file to the data-array */
- iDataRead = fread( HxWpt, 1, GM100_WPO_FILE_SIZE, file_in );
+ iDataRead = gbfread( HxWpt, 1, GM100_WPO_FILE_SIZE, file_in );
if (iDataRead == 0)
{
#define ATTR_OBJECTNAME "OBJNAM"
#define ATTR_SHIPNAME "shpnam"
-static void readVersion4( FILE* pFile);
+static void readVersion4(gbfile* pFile);
static void getAttr(const char *data, const char *attr, char **val, char seperator);
-static FILE *fd;
+static gbfile *fd;
static gbfile *ofd;
static
static void
hsa_ndv_rd_init(const char *fname)
{
- fd = xfopen(fname, "r", MYNAME);
+ fd = gbfopen(fname, "r", MYNAME);
psr = XML_ParserCreate(NULL);
if (!psr) {
int len;
char buf[MY_CBUF + 1];
- while ((len = fread(buf, 1, sizeof(buf) - 1, fd)))
+ while ((len = gbfread(buf, 1, sizeof(buf) - 1, fd)))
{
char *bad;
buf[len] = '\0';
if (NULL != strstr(buf, "nver=1"))
{//its the older format, not xml
- fseek(fd, 0, SEEK_SET);
+ gbfseek(fd, 0, SEEK_SET);
readVersion4(fd);
break;
}
{
*bad = REPLACEMENT_SIRIUS_ATTR_SEPARATOR;
}
- if (!XML_Parse(psr, buf, len, feof(fd))) {
+ if (!XML_Parse(psr, buf, len, gbfeof(fd))) {
fatal(MYNAME ":Parse error at %d: %s\n",
(int) XML_GetCurrentLineNumber(psr),
XML_ErrorString(XML_GetErrorCode(psr)));
if ( cdatastr ) {
xfree(cdatastr);
}
- fclose(fd);
+ gbfclose(fd);
}
static void
#define INVALID_TIME -1L
#define SOUNDARRAY_CHAR 'S'
-static int readRecord( FILE* pFile, const char* pRecName, char *recData);
-static int readPositionRecord( FILE* pFile, double* lat, double* lng, long* timeStamp);
+static int readRecord(gbfile* pFile, const char* pRecName, char *recData);
+static int readPositionRecord(gbfile* pFile, double* lat, double* lng, long* timeStamp);
-static void readVersion4( FILE* pFile)
+static void readVersion4(gbfile* pFile)
{
while( TRUE )
{
waypt_add(wpt_tmp);
}
- fclose(pFile);
+ gbfclose(pFile);
return;
}
// read a record to a file
-static int readRecord( FILE* pFile, const char* pRecName, char *recData)
+static int readRecord(gbfile* pFile, const char* pRecName, char *recData)
{
// get the rec name
int len;
for( len = 0; len < ED_REC_NAME_SIZE; len++)
{
- int c = fgetc( pFile);
+ int c = gbfgetc(pFile);
// if we hit EOF failed
if( c == EOF )
// get the rec data
for( len = 0; TRUE; len++)
{
- int c = fgetc( pFile);
+ int c = gbfgetc( pFile);
// if we hit EOF failed
if( c == EOF )
}
// read position
-static int readPositionRecord( FILE* pFile, double* lat, double* lng,
+static int readPositionRecord(gbfile* pFile, double* lat, double* lng,
long* timeStamp)
{
// read the lat record
const char *icon;
} psit_icon_mapping_t;
-static FILE *psit_file_in;
-static FILE *psit_file_out;
+static gbfile *psit_file_in;
+static gbfile *psit_file_out;
static short_handle mkshort_handle;
/* 2 = not written any tracks out
static void
psit_rd_init(const char *fname)
{
- psit_file_in = xfopen(fname, "r", MYNAME);
+ psit_file_in = gbfopen(fname, "r", MYNAME);
}
static void
psit_rd_deinit(void)
{
- fclose(psit_file_in);
+ gbfclose(psit_file_in);
}
static void
psit_wr_init(const char *fname)
{
- psit_file_out = xfopen(fname, "w", MYNAME);
+ psit_file_out = gbfopen(fname, "w", MYNAME);
}
static void
psit_wr_deinit(void)
{
- fclose(psit_file_out);
+ gbfclose(psit_file_out);
}
/*
* and write into buf.
*/
static void
-psit_getToken(FILE *psit_file, char *buf, size_t sz, psit_tokenSep_type delimType)
+psit_getToken(gbfile *psit_file, char *buf, size_t sz, psit_tokenSep_type delimType)
{
int c = -1;
*buf = 0;
if (delimType != EOL) {
- while ((c = fgetc (psit_file)) != EOF) {
+ while ((c = gbfgetc(psit_file)) != EOF) {
if (!isspace(c)) break;
}
}
- if (feof(psit_file)) return;
+ if (gbfeof(psit_file)) return;
if (delimType == EOL) {
- c = fgetc (psit_file);
+ c = gbfgetc(psit_file);
}
if (c == '#') {
- if (fgets(buf, sz, psit_file) == NULL) {
+ if (gbfgets(buf, sz, psit_file) == NULL) {
*buf = 0;
return;
}
if ((delimType == EOL) || (delimType == ltrimEOL)) {
*buf = c;
buf++;
- fgets(buf, sz-1, psit_file);
+ gbfgets(buf, sz-1, psit_file);
return;
}
while (sz--) {
*buf++ = c;
- if ((c = fgetc (psit_file)) == EOF) {
+ if ((c = gbfgetc (psit_file)) == EOF) {
*buf = 0;
return;
}
* MRCB
*/
static void
-psit_waypoint_r(FILE *psit_file, waypoint **wpt)
+psit_waypoint_r(gbfile *psit_file, waypoint **wpt)
{
int garmin_icon_num;
* MRCB
*/
static void
-psit_waypoint_w(FILE *psit_file, const waypoint *wpt)
+psit_waypoint_w(gbfile *psit_file, const waypoint *wpt)
{
int icon;
const char *ident;
char *src = 0; /* BUGBUG Passed to mkshort */
- fprintf(psit_file, "%11.6f,%11.6f,",
+ gbfprintf(psit_file, "%11.6f,%11.6f,",
wpt->latitude,
wpt->longitude);
if (wpt->altitude == unknown_alt)
- fprintf(psit_file, "********,");
+ gbfprintf(psit_file, "********,");
else
- fprintf(psit_file, "%8.2f,",
+ gbfprintf(psit_file, "%8.2f,",
wpt->altitude);
ident = global_opts.synthesize_shortnames ?
mkshort(mkshort_handle, src) :
wpt->shortname;
- fprintf(psit_file, " %-6s, ", ident);
+ gbfprintf(psit_file, " %-6s, ", ident);
icon = gt_find_icon_number_from_desc(wpt->icon_descr, PCX);
if (get_cache_icon(wpt) && wpt->icon_descr && (strcmp(wpt->icon_descr, "Geocache Found") != 0)) {
ident = psit_find_desc_from_icon_number(icon);
if (strlen(ident) == 0)
- fprintf(psit_file, "%1d\n", icon);
+ gbfprintf(psit_file, "%1d\n", icon);
else
- fprintf(psit_file, "%s\n", ident);
+ gbfprintf(psit_file, "%s\n", ident);
}
* MRCB
*/
static void
-psit_route_r(FILE *psit_file, route_head **rte)
+psit_route_r(gbfile *psit_file, route_head **rte)
{
char rtename[256];
unsigned int rte_num;
route_add_wpt(rte_head, thisWaypoint);
- if (feof(psit_file)) break;
+ if (gbfeof(psit_file)) break;
psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), wscomma);
}
* MRCB
*/
static void
-psit_routehdr_w(FILE *psit_file, const route_head *rte)
+psit_routehdr_w(gbfile *psit_file, const route_head *rte)
{
char hdr[20];
unsigned int rte_datapoints;
/* check for psitrex comment sign; replace with '$' */
while ((c = strchr(rname, '#'))) *c = '$';
- fprintf(psit_file, "Route: %s\n", rname);
+ gbfprintf(psit_file, "Route: %s\n", rname);
xfree(rname);
}
}
* MRCB
*/
static void
-psit_track_r(FILE *psit_file, route_head **trk)
+psit_track_r(gbfile *psit_file, route_head **trk)
{
char tbuf[100];
char trkname[256];
thisWaypoint->centiseconds = 0;
track_add_wpt(track_head, thisWaypoint);
- if (feof(psit_file)) break;
+ if (gbfeof(psit_file)) break;
psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), wscomma);
}
* MRCB
*/
static void
-psit_trackhdr_w(FILE *psit_file, const route_head *trk)
+psit_trackhdr_w(gbfile *psit_file, const route_head *trk)
{
char hdr[30];
unsigned int trk_datapoints;
/* check for psitrex comment sign; replace with '$' */
while ((c = strchr(tname, '#'))) *c = '$';
- fprintf (psit_file, "Track: %s\n", tname);
+ gbfprintf (psit_file, "Track: %s\n", tname);
xfree(tname);
}
* MRCB
*/
static void
-psit_trackdatapoint_w(FILE *psit_file, const waypoint *wpt)
+psit_trackdatapoint_w(gbfile *psit_file, const waypoint *wpt)
{
time_t t = wpt->creation_time;
struct tm *tmTime = gmtime(&t);
- fprintf(psit_file, "%11.6f,%11.6f,",
+ gbfprintf(psit_file, "%11.6f,%11.6f,",
wpt->latitude,
wpt->longitude);
if (wpt->altitude == unknown_alt)
- fprintf(psit_file, "********, ");
+ gbfprintf(psit_file, "********, ");
else
- fprintf(psit_file, "%8.2f, ",
+ gbfprintf(psit_file, "%8.2f, ",
wpt->altitude);
/* Following date time format is fixed and reveals the origin of PsiTrex (i.e. the UK) */
- fprintf(psit_file, "%02d/%02d/%02d %02d:%02d:%02d,",
+ gbfprintf(psit_file, "%02d/%02d/%02d %02d:%02d:%02d,",
tmTime->tm_mday,
tmTime->tm_mon+1,
tmTime->tm_year % 100,
tmTime->tm_min,
tmTime->tm_sec);
- fprintf(psit_file," %d\n", psit_track_state);
+ gbfprintf(psit_file," %d\n", psit_track_state);
psit_track_state = 0;
}
}
else break;
}
- } while (!feof(psit_file_in));
+ } while (!gbfeof(psit_file_in));
return;
#include "jeeps/gpsmath.h"
#include <ctype.h>
-static FILE *file_out;
+static gbfile *file_out;
static short_handle mkshort_handle;
static char *vcf_encrypt = NULL;
static void
wr_init(const char *fname)
{
- file_out = xfopen(fname, "w", MYNAME);
+ file_out = gbfopen(fname, "w", MYNAME);
mkshort_handle = mkshort_new_handle();
}
static void
wr_deinit(void)
{
- fclose(file_out);
+ gbfclose(file_out);
mkshort_del_handle(&mkshort_handle);
}
stripped_html = strip_html(s);
p = gstrsub(stripped_html, "\n", "\\n");
p2 = gstrsub(p, "<p>", "\\n");
- fputs(p2, file_out);
+ gbfputs(p2, file_out);
xfree(p);
xfree(p2);
xfree(stripped_html);
return;
p = gstrsub(s, "\n", "\\n");
- fputs(p, file_out);
+ gbfputs(p, file_out);
xfree(p);
}
lonint = abs((int) wpt->longitude);
latint = abs((int) wpt->latitude);
- fprintf(file_out, "BEGIN:VCARD\nVERSION:3.0\n");
- fprintf(file_out, "N:%s;%s;;;\n", wpt->description,wpt->shortname);
- fprintf(file_out, "ORG:%c%d %06.3f %c%d %06.3f\n", wpt->latitude < 0 ? 'S' : 'N', abs(latint), 60.0 * (fabs(wpt->latitude) - latint), wpt->longitude < 0 ? 'W' : 'E', abs(lonint), 60.0 * (fabs(wpt->longitude) - lonint));
+ gbfprintf(file_out, "BEGIN:VCARD\nVERSION:3.0\n");
+ gbfprintf(file_out, "N:%s;%s;;;\n", wpt->description,wpt->shortname);
+ gbfprintf(file_out, "ORG:%c%d %06.3f %c%d %06.3f\n", wpt->latitude < 0 ? 'S' : 'N', abs(latint), 60.0 * (fabs(wpt->latitude) - latint), wpt->longitude < 0 ? 'W' : 'E', abs(lonint), 60.0 * (fabs(wpt->longitude) - lonint));
if (wpt->url) {
- fprintf(file_out, "URL:%s\n", wpt->url);
+ gbfprintf(file_out, "URL:%s\n", wpt->url);
}
- fprintf(file_out, "NOTE:");
+ gbfprintf(file_out, "NOTE:");
vcf_print_utf(&wpt->gc_data.desc_short);
- fprintf(file_out, "\\n");
+ gbfprintf(file_out, "\\n");
vcf_print_utf(&wpt->gc_data.desc_long);
- fprintf(file_out, "\\n\\nHINT:\\n");
+ gbfprintf(file_out, "\\n\\nHINT:\\n");
if (vcf_encrypt) {
char *s = rot13(wpt->gc_data.hint);
vcf_print(s);
vcf_print(wpt->gc_data.hint);
}
- fprintf(file_out, "\nEND:VCARD\n");
+ gbfprintf(file_out, "\nEND:VCARD\n");
}
static void